using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class PaymentInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Code,
			Name,
			NameVN,
			Value1,
			Value2,
			Value3
		}
		private Int32 _ID;
		private String _Code;
		private String _Name;
		private String _NameVN;
		private Double _Value1;
		private Double _Value2;
		private Double _Value3;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String Code{	get{ return _Code;} set{_Code = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String NameVN{	get{ return _NameVN;} set{_NameVN = value;} }
		public Double Value1{	get{ return _Value1;} set{_Value1 = value;} }
		public Double Value2{	get{ return _Value2;} set{_Value2 = value;} }
		public Double Value3{	get{ return _Value3;} set{_Value3 = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public PaymentInfo()
		{
			_ID = 0;
			_Code = "";
			_Name = "";
			_NameVN = "";
			_Value1 = 0;
			_Value2 = 0;
			_Value3 = 0;
		}
		public PaymentInfo(
		Int32 ID,
		String Code,
		String Name,
		String NameVN,
		Double Value1,
		Double Value2,
		Double Value3
		)
		{
			_ID = ID;
			_Code = Code;
			_Name = Name;
			_NameVN = NameVN;
			_Value1 = Value1;
			_Value2 = Value2;
			_Value3 = Value3;
		}
		public PaymentInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_Code = dr[Field.Code.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Code.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_NameVN = dr[Field.NameVN.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NameVN.ToString()]);
				_Value1 = dr[Field.Value1.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.Value1.ToString()]);
				_Value2 = dr[Field.Value2.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.Value2.ToString()]);
				_Value3 = dr[Field.Value3.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.Value3.ToString()]);
			}
		}
		public PaymentInfo(PaymentInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Code = objEntr.Code;			
			_Name = objEntr.Name;			
			_NameVN = objEntr.NameVN;			
			_Value1 = objEntr.Value1;			
			_Value2 = objEntr.Value2;			
			_Value3 = objEntr.Value3;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Payment");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Code.ToString(), typeof(String)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.NameVN.ToString(), typeof(String)),
				new DataColumn(Field.Value1.ToString(), typeof(Double)),
				new DataColumn(Field.Value2.ToString(), typeof(Double)),
				new DataColumn(Field.Value3.ToString(), typeof(Double))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Code.ToString()] = _Code;
			row[Field.Name.ToString()] = _Name;
			row[Field.NameVN.ToString()] = _NameVN;
			row[Field.Value1.ToString()] = _Value1;
			row[Field.Value2.ToString()] = _Value2;
			row[Field.Value3.ToString()] = _Value3;
			return row;
		}
        #endregion InitTable
    }
}
